//
//  Home_BottomMesView.m
//  TY-C
//
//  Created by xyyl on 2024/3/29.
//

#import "Home_BottomMesView.h"
#import "ComonFile.h"

@implementation Home_BottomMesView

- (instancetype)initWithFrame:(CGRect)frame {
    if(self == [super initWithFrame:frame]){
        [self initViews];
        [self initFrames];
        self.backgroundColor = RGBColor(247, 247, 247);
    }
    return self;
}

- (void)initFrames {
  ///离左右 70
    CGFloat space = 30 *IPADSCALE;
    CGFloat toXorY = 60*IPADSCALE;
    CGFloat width = (self.frame.size.width - toXorY  * 2 - space * 4)/5 ;
    
    
    [_rMS0Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(toXorY);
        make.top.equalTo(self).offset(11*IPADSCALE);
        make.width.equalTo(@(width));
        make.height.equalTo(@(11*IPADSCALE));
    }];
    _rMS0Lab.text = @"RMS实时值";
    
    [self labCustom:_rMS0Lab];
    
    [_mesg0Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.width.equalTo(_rMS0Lab);
        make.height.equalTo(@(16.5 * IPADSCALE));
        make.top.equalTo(_rMS0Lab.mas_bottom).offset(2);
    }];
    _mesg0Lab.text = @"45μV";
    [self mesgCustom:_mesg0Lab];
    
    //
    [_rMS1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_rMS0Lab);
        make.left.equalTo(_rMS0Lab.mas_right).offset(space);
    }];
    _rMS1Lab.text = @"RMS最大值";
    
    [self labCustom:_rMS1Lab];
    
    [_mesg1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_mesg0Lab);
        make.left.equalTo(_rMS1Lab);
    }];
    _mesg1Lab.text = @"90μV";
    [self mesgCustom:_mesg1Lab];
    
    
    //
    [_rMS2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_rMS0Lab);
        make.left.equalTo(_rMS1Lab.mas_right).offset(space);
    }];
    _rMS2Lab.text = @"RMS最小值";
    
    [self labCustom:_rMS2Lab];
    
    [_mesg2Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_mesg0Lab);
        make.left.equalTo(_rMS2Lab);
    }];
    _mesg2Lab.text = @"20μV";
    [self mesgCustom:_mesg2Lab];
 
    //
    [_rMS3Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_rMS0Lab);
        make.left.equalTo(_rMS2Lab.mas_right).offset(space);
    }];
    _rMS3Lab.text = @"RMS平均值";
    
    [self labCustom:_rMS3Lab];
    
    [_mesg3Lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_mesg0Lab);
        make.left.equalTo(_rMS3Lab);
    }];
    _mesg3Lab.text = @"70μV";
    [self mesgCustom:_mesg3Lab];
    
    //
    [_fzLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_rMS0Lab);
        make.left.equalTo(_rMS3Lab.mas_right).offset(space);
    }];
    _fzLab.text = @"阈值";
    
    [self labCustom:_fzLab];
    
    [_mesgFzLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.width.height.equalTo(_mesg0Lab);
        make.left.equalTo(_fzLab);
    }];
    _mesgFzLab.text = @"70μV";
    [self mesgCustom:_mesgFzLab];
    _fzLab.textColor = RGBColor(10, 125, 175);
    _mesgFzLab.textColor = RGBColor(10, 125, 175);

    
    
}

- (void)mesgCustom:(UILabel *)lab {
    lab.font = [UIFont boldSystemFontOfSize:18];
    lab.textColor = RGBColor(51, 51, 51);
    lab.textAlignment = NSTextAlignmentLeft;
}

- (void)labCustom:(UILabel *)lab {
    lab.font = ZYQFONT(15);
    lab.textColor = RGBColor(102, 102, 102);
    lab.textAlignment = NSTextAlignmentLeft;
    
}

- (void)initViews {
    _rMS0Lab = [UILabel new];
    _rMS1Lab = [UILabel new];
    _rMS2Lab = [UILabel new];
    _rMS3Lab = [UILabel new];
    _fzLab = [UILabel new];

    _mesg0Lab = [UILabel new];
    _mesg1Lab = [UILabel new];
    _mesg2Lab = [UILabel new];
    _mesg3Lab = [UILabel new];
    _mesgFzLab = [UILabel new];
    
    [self addSubview:_rMS0Lab];
    [self addSubview:_rMS1Lab];
    [self addSubview:_rMS2Lab];
    [self addSubview:_rMS3Lab];
    [self addSubview:_fzLab];
    
    [self addSubview:_mesg0Lab];
    [self addSubview:_mesg1Lab];
    [self addSubview:_mesg2Lab];
    [self addSubview:_mesg3Lab];
    [self addSubview:_mesgFzLab];

}

@end
